<template>
  <section>
    <!--start 面包屑-->
    <div class="location">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{path:'/index'}">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{path:'/goods'}">商品</el-breadcrumb-item>
        <el-breadcrumb-item :to="{path:'/goods'}">商品列表</el-breadcrumb-item>
        <el-breadcrumb-item>商品新增</el-breadcrumb-item>
      </el-breadcrumb>
    	<help-components>
				<span slot="headText">{{helpData.templateName}}</span>
				<p slot="headDescText" v-html="helpData.templateRemark"></p>
				<div slot="helpContentWrap">
					<div v-for="(item,index) in helpData.questionAndAnswerArray">
						<h3>{{item.templateContent}}</h3>
						<p v-html="item.templateRemark"></p>
					</div>
				</div>
			</help-components>
    </div>
    <!--end 面包屑-->
		<!--start content-->
		<div class="wrap addGoodsWrap">
			<el-form :model="addGoodsData" :rules="rule" ref="ruleForm" label-width="100px" class="scroll formFontSizeMini">
				<!--start 基础信息-->
				<el-row :gutter="20">
					<el-col :span="24">
						<div class="title">
							基础信息
							<el-checkbox v-model="addGoodsData.basicInfo.isPutaway" size="small">立即上架</el-checkbox>
						</div>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="12">
						<el-form-item label="商品名称" prop="goodsName">
							<el-input v-model="addGoodsData.goodsName" placeholder="长度<128,必填"></el-input>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="品牌" prop="">
							 <el-select @change="vFun_brand_selectChange" popper-class="posi" class="selectWidth" v-model="addGoodsData.basicInfo.brandCode" placeholder="" ref="brandSelect">
					      <el-option v-for="(item,index) in addGoodsData.basicInfo.brandCodeList" :label="item.brandName" :value="item.brandCode"></el-option>
					      <el-option value='add' class="kael"><span class="iconfont" @click="vFun_brand_addBtn">&#xec52;&nbsp;新增商品品牌</span></el-option>
					    </el-select>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="12">
						<el-form-item label="商品分类" prop="categoryCode">
							<el-input v-show="false" v-model="addGoodsData.categoryCode"></el-input>
							<div class="departmentSelectDiv">
            		<span @click.stop="departmentFn" :class="{redBorder:addGoodsData.categoryRedB}">{{addGoodsData.basicInfo.categoryName}}</span>
            		<i class="el-icon-caret-bottom" :class="{up:addGoodsData.basicInfo.treeShow}"></i>
            		<transition name="selectSlide">
            			<div class="goodsCate" v-show="addGoodsData.basicInfo.treeShow">
		            		<el-tree
		            			class="departmentTree"
		                  :data="addGoodsData.basicInfo.categoryTree"
		                  :props="addGoodsData.basicInfo.categoryProps"
		                  node-key="treeCode"
		                  accordion
		                  :expand-on-click-node="false"
		                  @node-click="handleNodeClick">
		                </el-tree>
		                <div class="goodsCateBtn" @click="vFun_goodsCate_addBtn"><span class="iconfont">&#xec52;&nbsp;新增商品分类</span></div>
	                </div>
                </transition>
            </div>
						</el-form-item>
					</el-col>

					<el-dialog title="新增商品分类" :close-on-click-modal="false" :show-close='false' custom-class="goodsCate_dialogShow" :visible.sync="vue_goodsCate_dialogShow">
					  <el-form :model="vue_goodsCate_addData" :rules="vue_rules" ref='addGoodsCate'>
					    <el-form-item label="分类名称" label-width="90px" prop="categoryName">
					      <el-input v-model="vue_goodsCate_addData.categoryName" auto-complete="off"></el-input>
					    </el-form-item>
					    <el-form-item label="上级分类" label-width="90px">
					        <el-input v-show="false" v-model="vue_goodsCate_addData.categoryParentCode"></el-input>
							<div class="departmentSelectDiv">
								<span @click.stop="vFun_departmentFn">{{vue_goodsCate_addData.categoryParentName}}</span>
								<i class="el-icon-caret-bottom" :class="{up:vue_goodsCate_addData.treeShow}"></i>
								<transition name="selectSlide">
									<div class="goodsCateAdd" v-show="vue_goodsCate_addData.treeShow">
										<el-tree class="departmentTreeAdd" :data="vue_goodsCate_dialogData" :props="addGoodsData.basicInfo.categoryProps" node-key="treeCode" accordion :expand-on-click-node="false" @node-click="vFun_categoryCode_treeSelect">
										</el-tree>
									</div>
								</transition>
							</div>
					    </el-form-item>
					  </el-form>
					  <div slot="footer">
					    <el-button type="primary" @click="vFun_goodsCate_addOk">确 定</el-button>
					    <el-button @click="vue_goodsCate_dialogShow = false">取 消</el-button>
					  </div>
					</el-dialog>

					<el-col :span="12">
						<el-form-item label="排序值" prop="" class="orderByDiv">
								<el-input v-model="addGoodsData.basicInfo.orderBy" placeholder=""></el-input>
								<span class="btnSpan orderByBtnAdd" onselectstart="return false" @click="orderByAdd">+</span>
								<span class="btnSpan orderByBtnSub" onselectstart="return false" @click="orderBySub">-</span>
						</el-form-item>
					</el-col>
				</el-row>
				<el-row :gutter="20">
					<el-col :span="12">
						<el-form-item label="计量单位" prop="goodsNumUnitName">
							<el-select @change="vFun_goodsNumUnit_selectChange" popper-class="posi" class="selectWidth" v-model="addGoodsData.goodsNumUnitName" placeholder="">
					      <el-option v-for="(item,index) in addGoodsData.basicInfo.goodsNumUnitList" :label="item.unitName" :value="item.unitName"></el-option>
					      <el-option value='add' class="kael"><span class="iconfont" @click="vFun_goodsNumUnit_addBtn">&#xec52;&nbsp;新增计量单位</span></el-option>
					    </el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item label="搜索关键字" prop="">
								<el-input v-model="addGoodsData.basicInfo.goodsKeywords" placeholder=""></el-input>
						</el-form-item>
					</el-col>
				</el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <el-form-item label="显示名称" prop="">
                <el-input v-model="addGoodsData.basicInfo.goodsShowName" placeholder=""></el-input>
            </el-form-item>
          </el-col>
        </el-row>
				<el-row :gutter="20">
					<el-col :span="24">
						<el-form-item label="商品标签" prop="">
							<label class="goodsLabel" v-for="(item,index) in addGoodsData.basicInfo.goodsTagsList">
								<span class="checkboxSpan" :class="{active:item.isCheckbox}">
									<input type="checkbox" class="checkboxInput" v-model="item.isCheckbox">
								</span>
								<span class="checkboxText">{{item.ddlistName}}</span>
							</label>
						</el-form-item>
					</el-col>
				</el-row>
				<!--end 基础信息-->
				<!--start 商品规格-->
				<el-row :gutter="20">
					<el-col :span="24">
						<div class="title">
							商品规格
						</div>
					</el-col>
				</el-row>
				<el-row>
					<el-col :span="24">
						<div class="tableWrap">
							<div class="tableHeader">
								<el-checkbox v-model="addGoodsData.goodsStandard.moreStandard" size="small">设置商品多规格</el-checkbox>
							</div>
							<table border="0" cellspacing="0" cellpadding="0" class="setStandardTable" v-show="addGoodsData.goodsStandard.moreStandard">
								<colgroup>
									<col style="width: 4%" />
	                <col style="width: 13%" />
	                <col style="width: 83%" />
            		</colgroup>
								<tr>
									<th></th>
									<th>规格名称</th>
									<th>
										规格值
										<span>(可使用键盘“回车键”快速添加规格值)</span>
									</th>
								</tr>

								<tr v-if="addGoodsData.goodsStandard.addStandard.one.isShow">
									<td class="textAlignC borderT borderR cursorPo" @click="subStandardOne">
										<i class="el-icon-minus"></i>
									</td>
									<td class="borderT borderR">
										<el-input v-model="addGoodsData.goodsStandard.addStandard.one.standardName"></el-input>
									</td>
									<td class="borderT">
										<el-select
											class="selectWidth"
									    v-model="addGoodsData.goodsStandard.addStandard.one.standardVal"
									    multiple
									    filterable
									    default-first-option
									    allow-create>
									    <el-option
									      v-for="item in addGoodsData.goodsStandard.addStandard.one.standardList"
									      :key="item.value"
									      :value="item.value">
									    </el-option>
									  </el-select>
									</td>
								</tr>
								<tr v-if="addGoodsData.goodsStandard.addStandard.two.isShow">
									<td class="textAlignC borderT borderR cursorPo" @click="subStandardTwo">
										<i class="el-icon-minus"></i>
									</td>
									<td class="borderT borderR">
										<el-input v-model="addGoodsData.goodsStandard.addStandard.two.standardName"></el-input>
									</td>
									<td class="borderT">
										<el-select
											class="selectWidth"
									    v-model="addGoodsData.goodsStandard.addStandard.two.standardVal"
									    multiple
									    filterable
									    default-first-option
									    allow-create>
									    <el-option
									      v-for="item in addGoodsData.goodsStandard.addStandard.two.standardList"
									      :key="item.value"
									      :value="item.value">
									    </el-option>
									  </el-select>
									</td>
								</tr>
								<tr v-if="addGoodsData.goodsStandard.addStandard.three.isShow">
									<td class="textAlignC borderT borderR cursorPo" @click="subStandardThree">
										<i class="el-icon-minus"></i>
									</td>
									<td class="borderT borderR">
										<el-input v-model="addGoodsData.goodsStandard.addStandard.three.standardName"></el-input>
									</td>
									<td class="borderT">
										<el-select
											class="selectWidth"
									    v-model="addGoodsData.goodsStandard.addStandard.three.standardVal"
									    multiple
									    filterable
									    default-first-option
									    allow-create>
									    <el-option
									      v-for="item in addGoodsData.goodsStandard.addStandard.three.standardList"
									      :key="item.value"
									      :value="item.value">
									    </el-option>
									  </el-select>
									</td>
								</tr>

								<tr v-show="addGoodsData.goodsStandard.addStandard.addBtn">
									<td colspan="3" class="borderT cursorPo" style="padding-left: 20px;">
										<i @click="addStandardLine" class="el-icon-plus addBtnI">添加规格</i>
									</td>
								</tr>
							</table>
							<div class="batchOper">
								<span>批量填充：</span>
								<span style="margin-right: 10px;width: 200px;">
									<el-input placeholder="市场价"  v-model="addGoodsData.goodsStandard.batchFill.pic"></el-input>
								</span>
								<!--<span style="margin-right: 10px;width: 200px;">
									<el-input placeholder="数量" v-model="addGoodsData.goodsStandard.batchFill.cou"></el-input>
								</span>-->
								<span style="width: 200px;">
									<el-input placeholder="条形码" v-model="addGoodsData.goodsStandard.batchFill.barCode"></el-input>
								</span>
							</div>
							<table border="0" cellspacing="0" cellpadding="0" class="showStandardTable">
								<colgroup>
									<col style="width: 4%" />
	                <col style="width: 5%" />
	                <col style="width: 10%" />
	                <col style="width: 10%" />
	                <col style="width: 10%" />
	                <col style="width: 20%" />
            		</colgroup>
								<tr>
									<th class="borderR"></th>
									<th class="borderR">主图</th>
									<th class="borderR" v-show="addGoodsData.goodsStandard.addStandard.one.isShow">{{addGoodsData.goodsStandard.addStandard.one.standardName}}</th>
									<th class="borderR" v-show="addGoodsData.goodsStandard.addStandard.two.isShow">{{addGoodsData.goodsStandard.addStandard.two.standardName}}</th>
									<th class="borderR" v-show="addGoodsData.goodsStandard.addStandard.three.isShow">{{addGoodsData.goodsStandard.addStandard.three.standardName}}</th>
									<th class="borderR">市场价（元）</th>
									<!--<th class="borderR">数量</th>-->
									<th>条形码</th>
								</tr>
								<tr @mouseenter="trHoverFnEnter(index)" @mouseleave="trHoverFnLeave(index)" v-for="(item,index) in addGoodsData.goodsStandard.saleGoodsSkuViewVoList">
									<td @click="delStandardFn(index)" class="borderR borderT cursorPo">{{item.standardIsDelText}}</td>
									<td class="borderR borderT cursorPo addPicTd" style="padding: 0;" @click.stop="nowIndex(index)">
											<el-upload
											  class="avatar-uploader"
											  :class="{active:!item.standardImg,default:!addGoodsData.goodsStandard.canUpload || !item.canUpload}"
											  :disabled="!addGoodsData.goodsStandard.canUpload || !item.canUpload"
											  :action="addGoodsData.uploadUrl"
											  :show-file-list="false"
												:data="addGoodsData.goodsStandard.uploadData"
											  :on-success="handleAvatarSuccess"
											  :on-error="handleAvatarError"
											  :on-progress="handleAvatarProgress"
											  :on-change="handleAvatarChange"
											  :before-upload="beforeAvatarUpload">
											  <img v-if="item.standardImg" :src="item.standardImg" class="avatar">
											  <i v-else class="avatar-uploader-icon" :class="{'el-icon-plus':!item.uploading,'el-icon-loading':item.uploading}"></i>
											</el-upload>
									</td>
									<td class="borderR borderT" v-show="addGoodsData.goodsStandard.addStandard.one.isShow">{{item.standardValOne}}</td>
									<td class="borderR borderT" v-show="addGoodsData.goodsStandard.addStandard.two.isShow">{{item.standardValTwo}}</td>
									<td class="borderR borderT" v-show="addGoodsData.goodsStandard.addStandard.three.isShow">{{item.standardValThree}}</td>
									<td class="borderT">
										<el-input v-model="item.standardPic" :disabled="!item.standardIsDel"></el-input>
									</td>
									<td class="borderT">
										<el-input v-model="item.standardBarCode" :disabled="!item.standardIsDel"></el-input>
									</td>
								</tr>
							</table>
						</div>
					</el-col>
				</el-row>
				<!--end 商品规格-->
					<!--start 商品价格-->
				<el-row :gutter="20">
					<el-col :span="24">
						<div class="title Tbuttom">
							商品价格
						</div>
					</el-col>
				</el-row>
				<el-row :gutter="0">
					<!--<el-col :span="6">
						<el-form-item label="市场价" prop="goodsSalePrice">
							<el-input v-model="addGoodsData.goodsSalePrice"></el-input>
						</el-form-item>
					</el-col>-->
					<el-col :span="6">
						<el-form-item label="参考成本价" prop="goodsSalePrice1">
							<el-input v-model="addGoodsData.goodsSalePrice1"></el-input>
						</el-form-item>
					</el-col>
				</el-row>
				<div class="addgoodTab" style="margin-bottom:40px;">
				  <el-table
				    :data="memberGradeData"
				    border
				    :align="center"
				    style="width: 100%">
				    <el-table-column
				    	prop="gradeName"
				      label="客户级别"
				      min-width="700"
				      align="center">
				    </el-table-column>
				    <el-table-column
				    	prop="gradeDiscount"
				      label="默认折扣"
				      min-width="150"
				      align="center">
					      <template scope="scope">
			            <span>{{scope.row.gradeDiscount}}%</span>
			          </template>
				    </el-table-column>
				    <!--<el-table-column
				    	prop="gradePriceValue"
				      label="折扣价"
				      min-width="180"
				      align="center">
				      <template scope="scope">
				      	<el-input v-model="scope.row.gradePriceValue"></el-input>
				      </template>
				    </el-table-column>-->
				  </el-table>
				  </div>
				<!--end 商品价格-->
				<!--start 商品图片-->
				<el-row :gutter="20">
					<el-col :span="24">
						<div class="title">
							商品图片
						</div>
					</el-col>
				</el-row>
				<el-row :gutter="20" style="padding-left: 10px;margin-bottom: 22px;">
					<el-upload
						:action="addGoodsData.uploadUrl"
						list-type="picture-card"
						:disabled="!addGoodsData.goodsPic"
						:data="addGoodsData.goodsPic.uploadData"
						:before-upload="picBeforeAvatarUpload"
						:on-preview="picPreview"
						:on-change="picChange"
						:on-remove="picRemove"
						:on-success="picSuccess">
					  <i class="el-icon-plus">
					  </i>
					</el-upload>
					<el-dialog v-model="addGoodsData.goodsPic.dialogVisible" size="tiny">
					  <img width="100%" :src="addGoodsData.goodsPic.dialogImageUrl" alt>
					</el-dialog>
				</el-row>
				<!--end 商品图片-->
				<!--start 商品描述-->
				<el-row :gutter="20">
					<el-col :span="24">
						<el-tabs v-model="addGoodsData.goodsDes.title" class="addGoodsTabs" @tab-click="handleClick">
					    <el-tab-pane label="商品描述" name="1">
					    	<script id="addGoodsEditor1" type="text/plain" style="width:99%;height:400px;"></script>
					    </el-tab-pane>
					    <el-tab-pane label="售后保障" name="2">
					    	<script id="addGoodsEditor2" type="text/plain" style="width:99%;height:400px;"></script>
					    </el-tab-pane>
					  </el-tabs>
					</el-col>
				</el-row>
				<!--<el-row :gutter="20" style="padding-left: 10px;margin-bottom: 22px;">
					<vue-u-editor ref="ueditor" @ready="editorReady" class="ueditor" style="width:100%;height: 400px;margin-top:30px;"></vue-u-editor>-->
					<!--<quill-editor class="quillEditor" ref="myTextEditor" v-model="addGoodsData.goodsDes.content" :config="addGoodsData.goodsDes.editorOption"></quill-editor>-->
				<!--</el-row>-->
				<!--end 商品描述-->
			</el-form>
		</div>
		<div class="btnBox" :class="{btnBox1:!$store.state.headFold}">
			<el-button type="primary" @click="saveFn" :disabled="clickBtn">保存</el-button>
			<el-button @click="cancel">取消</el-button>
		</div>
		<!--end content-->
  </section>
</template>


<script>
	const UE = require('UE');// eslint-disable-line
	import VueCoreImageUpload  from 'vue-core-image-upload';
	import helpComponents from '../../../components/help/help'
	export default {
		data(){
			var category = (rule, value, callback) => {
				if(!value) {
					this.addGoodsData.categoryRedB = true;
					return callback(new Error('商品分类不能为空'));
				}else{
					this.addGoodsData.categoryRedB = false;
					callback();
				}
			};
			var goodsSalePrice = (rule, value, callback) => {
				if(!value) {
					return callback(new Error('市场价不能为空'));
				}else if(isNaN(Number(value))){
					return callback(new Error('请输入数字'));
				}else{
					callback();
				}
			};
			var goodsSalePrice1 = (rule, value, callback) => {
				if(!value) {
					return callback(new Error('成本价不能为空'));
				}else if(isNaN(Number(value))){
					return callback(new Error('请输入数字'));
				}else{
					callback();
				}
			};
			return {
				vue_goodsCate_dialogShow:false,  //商品分类的下拉项里的addBtn点击后的弹框，显示与否控制变量
				vue_goodsCate_dialogData:[],  //新增商品分类的data
				vue_goodsCate_addData:{  //新增商品分类的data
					categoryName:'',
					categoryParentCode:'-1',
					categoryParentName:'根类别',
					treeShow:false
				},
				vue_rules:{
					categoryName: [{required: true, message: '分类名称不能为空', trigger: 'blur'},{required: true,min:0,max:10,message: '分类名称不能超过十个字',trigger: 'blur'}],
				},

       	clickBtn:false,                 //请求数据后禁用按钮
				helpData:{
					templateName:"",
					templateRemark:"",
					questionAndAnswerArray:[]
				},
				center:"",
				 memberGradeData: [],
       	 multipleSelection: [],
				addGoodsData:{
					goodsName:"", //商品名称
					categoryCode:"", //商品分类code
					categoryRedB:false,
					goodsNumUnitName:"", //计量单位
					goodsSalePrice:"",//参考市场价
					goodsSalePrice1:"",//成本价
					basicInfo:{
						isPutaway:false, //是否立即上架
						goodsName:"", //商品名称
						brandCodeList:[], //所有的商品品牌
						brandCode:"", //商品品牌
						categoryTree:[],//商品分类treeData
						categoryProps:{ //商品分类props
							children: 'children',
          		label: 'treeName'
						},
						categoryName:"",//商品分类name
						treeShow:false,
						categoryCode:"", //商品分类code
						orderBy:"", //排序值
						goodsNumUnitCode:"", //计量单位
						goodsNumUnitName:"",
						goodsNumUnitList:[], //计量单位List
						goodsKeywords:"", //搜索关键字123
            goodsShowName:"",   //显示名称
						goodsTags:"",  //商品标签
						goodsTagsList:[], //商品标签List
					},
					goodsStandard:{
						uploadImgIndex:0, //多规格上传图片时的index
						canUpload:true,  //是否可以上传
						moreStandard:false,
						addStandard:{
							one:{
								isShow:true,
								standardName:"规格",
								standardVal:[], //规格1的valList
								standardList:[] //规格1的optionList
							},
							two:{
								isShow:false,
								standardName:"规格2",
								standardVal:[],//规格2的valList
								standardList:[]//规格2的optionList
							},
							three:{
								isShow:false,
								standardName:"规格3",
								standardVal:[],//规格3的valList
								standardList:[]//规格3的optionList
							},
							addBtn:true
						},
						batchFill:{
							pic:"",
							cou:"",
							barCode:""
						},
						allStandardViewVoList:[], //包含规格一规格二规格三的newArr
						standardViewVoList:[], //组合规格一规格二规格三后的newArr
						saleGoodsSkuViewVoList:[{  //拆分newArr后，用来循环渲染数据的Arr
							standardIsDel:true,   //控制是否点击 了删除（单选删除）
							standardIsDelText:"1",
							standardImg:"",
							standardValOne:"无",
							standardValTwo:"",
							standardValThree:"",
							standardPic:"",
							standardBarCode:"",
							canUpload:true,
							uploading:false
						}],
						saleGoodsSkuViewVoListAjax:[], //save里需要上传的规格集合
						standardPicAjax:"",
						uploadData:{
							"moduleName":"sale",
							"fileName":""
						}
					},
					goodsPic:{
						goodsPicUrls:"",
						dialogImageUrl:"",
						dialogVisible:false,
						canUpload:true,
						fileListLength:0,
						uploadData:{
							"moduleName":"sale",
							"fileName":"",
							"fromTable":"SaleGoods",
							"fromCode":""
						}
					},
					goodsDes:{
						editor1:null,
						editor2:null,
						title:"1",
						editorOption:{
                // something config
            },
						content:"在这里输入。。",
						goodsDesc:"",
						goodsDesc1:""
					},
					uploadUrl:"/v3/misc/common/uploadFile",
					freightCode:"",	// 运费模板代码
				},
				rule:{
					goodsName:[{required: true, message: '商品名称不能为空', trigger: 'blur'},{required: true,min:0,max:128, message: '商品名称不能大于128个字符', trigger: 'blur'}],
					categoryCode:[{required: true, validator: category, trigger: 'blur'}],
					goodsNumUnitName:[{required: true, message: '计量单位不能为空', trigger: 'blur'}],
					goodsSalePrice:[{required: true, validator: goodsSalePrice, trigger: 'blur'}],
					goodsSalePrice1:[{required: true, validator: goodsSalePrice1, trigger: 'blur'}]
				},
				transFreightOption:[],
			}
		},
		components: {
    	VueCoreImageUpload,helpComponents
    },
		watch:{
			"addGoodsData.goodsSalePrice":function(val){
				if(this.memberGradeData.length&&!isNaN(Number(val))){
					this.memberGradeData.forEach((item,index,arr)=>{
						item.gradePriceValue= (val*item.gradeDiscount*0.01).toFixed(2)
					})
				}
			},
			"addGoodsData.goodsStandard.moreStandard":function(val,oldVal){  //监听设置商品多规格这个状态有没有被改变
				if(!val){
					this.addGoodsData.goodsStandard.addStandard.one.isShow = true;
					this.addGoodsData.goodsStandard.addStandard.one.standardName = "规格";
					this.addGoodsData.goodsStandard.addStandard.one.standardVal = [];
					this.addGoodsData.goodsStandard.addStandard.one.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.two.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.two.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.three.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.three.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardList = [];
				}else{
					this.addGoodsData.goodsStandard.addStandard.one.standardName = "规格1";
				}
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList = [{standardIsDel:true,standardIsDelText:"1",standardImg:"",standardValOne:"无",	standardValTwo:"",standardValThree:"",standardPic:"",standardBarCode:"",canUpload:true,uploading:false}]
			},
			"addGoodsData.goodsStandard.addStandard.one.standardVal":function(val,oldVal){  //监听多规格的第一个规格的value变化
				this.newStandardArr();
			},
			"addGoodsData.goodsStandard.addStandard.two.standardVal":function(val,oldVal){  //监听多规格的第二个规格的value变化
				this.newStandardArr();
			},
			"addGoodsData.goodsStandard.addStandard.three.standardVal":function(val,oldVal){  //监听多规格的第三个规格的value变化
				this.newStandardArr();
			},
			"addGoodsData.goodsStandard.standardViewVoList":function(val,oldVal){  //监听多规格输入的是否有变化，从而时时更新表格
				if(val.length){
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList=[];  //如果多规格数组为空，就清空用来渲染多规格表格数组
				}else{  //如果多规格数组不为空，则设置渲染多规格表格数组为默认值
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList = [{standardIsDel:true,standardIsDelText:"1",standardImg:"",standardValOne:"无",	standardValTwo:"",standardValThree:"",standardPic:"",standardBarCode:"",canUpload:true,uploading:false}]
				}
				val.forEach((item,index,arr)=>{
					this.$set(this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList,index,{
						standardIsDel:true,
						standardIsDelText:index+1,
						standardImg:"",
						standardValOne:item.split(",")[0],
						standardValTwo:item.split(",")[1],
						standardValThree:item.split(",")[2],
						standardPic:"",
						standardBarCode:"",
						canUpload:true,
						uploading:false
					})
				})
			},
			"addGoodsData.goodsStandard.batchFill.pic":function(val,oldVal){  //批量输入金额
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList.forEach((item,index,arr)=>{
					item.standardPic = val;
				})
			},
			"addGoodsData.goodsStandard.batchFill.barCode":function(val,oldVal){  //批量输入条形码
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList.forEach((item,index,arr)=>{
					item.standardBarCode = val;
				})
			},
			"addGoodsData.goodsName":function(val,oldVal){  //这里我认为是不用监听的，但是我不敢删
				this.addGoodsData.basicInfo.goodsName = val;
			},
			"addGoodsData.goodsNumUnitName":function(val,oldVal){ //这里我认为是不用监听的，但是我不敢删
				this.addGoodsData.basicInfo.goodsNumUnitName = val;
			}
		},
		methods:{
			vFun_brand_addBtn(){  //品牌下拉的新增按钮新增
				this.addGoodsData.basicInfo.brandCode_old=this.addGoodsData.basicInfo.brandCode;
				this.$prompt('品牌名称', '新增商品品牌', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          customClass: "surePay clearfixBox",
          cancelButtonClass: 'fr',
          confirmButtonClass: 'fr',
          inputPattern: /.+/,
          inputErrorMessage: '商品品牌不能为空'
        }).then(({ value }) => {
          this.axios({
              method: 'POST',
              url: '/v3/goods/brands',
              data: {
                "brandName": value
              }
            }).then((res) => {
	            this.Public.openSuccess(this,"操作成功！");
	            this.queryBrandList();
            }).catch((err)=>{
            	this.Public.openError(this,err.response.data);
            });
        }).catch(() => {
          //取消
        });
			},
			vFun_brand_selectChange(val){  //当点击的是新增品牌的按钮时，通过这个方法，把select的选择的值清空。
				if(val==='add'){
					this.addGoodsData.basicInfo.brandCode=this.addGoodsData.basicInfo.brandCode_old;
				};
			},
			vFun_goodsNumUnit_addBtn(){  //计量单位下拉的新增按钮新增
				this.addGoodsData.goodsNumUnitName_old=this.addGoodsData.goodsNumUnitName;
				this.$prompt('单位名称', '新增计量单位', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          customClass: "surePay clearfixBox",
          cancelButtonClass: 'fr',
          confirmButtonClass: 'fr',
          inputPattern: /.+/,
          inputErrorMessage: '计量单位不能为空'
        }).then(({ value }) => {
          this.axios({
	  					method: 'post',
	  					url: '/v3/basic/units',
						data:{
							"unitName":value
						}
					}).then((res) => {
						this.Public.openSuccess(this,'操作成功！');
						this.queryUnit();
					}).catch((err)=>{
            this.Public.openError(this,err.response.data);
					});
        }).catch(() => {
          //取消
        });
			},
			vFun_goodsNumUnit_selectChange(val){  //当点击的是新增单位的按钮时，通过这个方法，把select的选择的值清空。
				if(val==='add'){
					this.addGoodsData.goodsNumUnitName=this.addGoodsData.goodsNumUnitName_old;
				};
			},
			vFun_goodsCate_addBtn() {
				this.vue_goodsCate_dialogShow=true;
			},
			vFun_departmentFn() {
				this.vue_goodsCate_addData.treeShow = !this.vue_goodsCate_addData.treeShow;
			},
			vFun_categoryCode_treeSelect(data) {
				this.vue_goodsCate_addData.categoryParentCode=data.treeCode;
				this.vue_goodsCate_addData.categoryParentName=data.treeName;
				this.vue_goodsCate_addData.treeShow=false;
			},
			vFun_goodsCate_addOk(){
				this.$refs['addGoodsCate'].validate(b=>{
					if(b){
						this.axios({
			              method: 'post',
			              url: "/v3/goods/categorys",
			              data: {
			                "categoryName": this.vue_goodsCate_addData.categoryName,
			                "categoryParentCode": this.vue_goodsCate_addData.categoryParentCode
			              }
			            }).then((res) => {
							this.vue_goodsCate_dialogShow=false;
			                this.$refs['addGoodsCate'].resetFields();
			                this.Public.openSuccess(this,'操作成功！');
			                this.querycategoryList();
			            }).catch((err)=>{
			                this.$refs['addGoodsCate'].resetFields();
			                this.Public.openError(this,err.response.data);
			            });
					}else{
						return false;
					}
				})
			},
			vFun_goodsCate_cancel(){
				this.$refs['addGoodsCate'].resetFields();
				this.vue_goodsCate_dialogShow=false;
			},
			systemTemplateAjax(){
				this.axios({
					method:"GET",
					url:"/v3/system/templates/001000000013"
				}).then((res)=>{
						this.helpData.templateName = res.data.templateName;
						this.helpData.templateRemark = res.data.templateRemark;
						this.helpData.questionAndAnswerArray = res.data.questionAndAnswerArray;
				}).catch((err)=>{
					this.Public.openError(this,err.response.data)
				})
			},
			/* start 请求商品品牌 */
			queryBrandList(){
				this.axios({
	        method: 'post',
	        url: "/v3/goods/brands/list",
	        data:{}
	      }).then((res) => {
	          this.addGoodsData.basicInfo.brandCodeList = res.data.list;
	      });
			},
			/* end 请求商品品牌 */
			/* start 商品分类 */
			handleNodeClick(data) {
      	this.addGoodsData.basicInfo.categoryCode = data.treeCode;
      	this.addGoodsData.basicInfo.categoryName = data.treeName;
      	this.addGoodsData.basicInfo.treeShow = false;
      	this.addGoodsData.categoryCode = data.treeCode;
      },
      departmentFn(){
      	this.addGoodsData.basicInfo.treeShow = !this.addGoodsData.basicInfo.treeShow;
      },
      	//商品分类
      querycategoryList(){
      	this.axios({
	        method: 'post',
	        url: "/v3/goods/categorys/queryTree"
	      }).then((res) => {
					this.addGoodsData.basicInfo.categoryTree = JSON.parse(JSON.stringify(res.data));
					this.vue_goodsCate_dialogData = JSON.parse(JSON.stringify(res.data));
					this.vue_goodsCate_dialogData.unshift({'treeName':'根类别','treeCode':'-1'});
	      }).catch((err)=>{

	      });
      },
			/* end 商品分类 */
			/* start 排序 */
			orderByAdd(){
				if(!isNaN(parseInt(this.addGoodsData.basicInfo.orderBy))){
					this.addGoodsData.basicInfo.orderBy = parseInt(this.addGoodsData.basicInfo.orderBy)+1;
				}else{
					this.addGoodsData.basicInfo.orderBy = 0;
				}
			},
			orderBySub(){
				if(!isNaN(parseInt(this.addGoodsData.basicInfo.orderBy))){
					if(parseInt(this.addGoodsData.basicInfo.orderBy)>0){
						this.addGoodsData.basicInfo.orderBy = parseInt(this.addGoodsData.basicInfo.orderBy)-1;
					}
				}else{
					this.addGoodsData.basicInfo.orderBy = 0;
				}
			},
			/* start 排序 */
			/* start 计量单位 */
			queryUnit(){
				this.axios({
					method: 'post',
					url:"/v3/basic/units/list",
					data:{}
				}).then((res) => {
						this.addGoodsData.basicInfo.goodsNumUnitList = res.data.list;
				});
			},
			/* end 计量单位 */
			/* start 商品标签 */
			queryBasicDdtype(){
				this.axios({
					method: "post",
					url: "/v3/basic/ddlists/00100000001/listAll",
					data: {}
				}).then((res) => {
						res.data.list.forEach((item,index,arr)=>{
							item.isCheckbox = false;
						})
						this.addGoodsData.basicInfo.goodsTagsList = res.data.list;
				});
			},
			/* start 商品标签 */
			/* start 客户级别 */
			queryListAll(){
      			this.axios({
							method: 'POST',
							url:"/v3/member/grades/list",
							data:{}
						}).then((res) => {
							res.data.list.forEach((item,index,arr)=>{
								this.$set(this.memberGradeData,index,{gradeCode:item.gradeCode,gradeName:item.gradeName,gradeDiscount:item.gradeDiscount,gradePriceValue:0})
							})
						}).catch((err)=>{
							this.Public.openError(this,err.response.data)
						});
      		},
			/* end 客户级别 */
			/* start 商品规格 */
			addStandardLine(){
				if(this.addGoodsData.goodsStandard.addStandard.two.isShow){
					this.addGoodsData.goodsStandard.addStandard.three.isShow = true;
					this.addGoodsData.goodsStandard.addStandard.addBtn = false;
				}else{
					this.addGoodsData.goodsStandard.addStandard.two.isShow = true;
				}
			},
			subStandardOne(){
				if(this.addGoodsData.goodsStandard.addStandard.two.isShow&&this.addGoodsData.goodsStandard.addStandard.three.isShow){
					this.addGoodsData.goodsStandard.addStandard.three.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.three.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.addBtn = true;
				}else if(this.addGoodsData.goodsStandard.addStandard.two.isShow){
					this.addGoodsData.goodsStandard.addStandard.two.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.two.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.addBtn = true;
				}else{
					this.Public.openError(this,"规格启用时，必须保留一个规格")
				}
			},
			subStandardTwo(){
				if(this.addGoodsData.goodsStandard.addStandard.three.isShow){
					this.addGoodsData.goodsStandard.addStandard.three.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.three.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.three.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.addBtn = true;
				}else{
					this.addGoodsData.goodsStandard.addStandard.two.isShow = false;
					this.addGoodsData.goodsStandard.addStandard.two.standardName = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardVal = "";
					this.addGoodsData.goodsStandard.addStandard.two.standardList = [];
					this.addGoodsData.goodsStandard.addStandard.addBtn = true;
				}
			},
			subStandardThree(){
				this.addGoodsData.goodsStandard.addStandard.three.isShow = false;
				this.addGoodsData.goodsStandard.addStandard.three.standardName = "";
				this.addGoodsData.goodsStandard.addStandard.three.standardVal = "";
				this.addGoodsData.goodsStandard.addStandard.three.standardList = [];
				this.addGoodsData.goodsStandard.addStandard.addBtn = true;
			},
			newStandardArr(){  //把多个规格的数组组合成一个数组，例[1,3]+[2,4]=>[12,14,32,34]
				if(this.addGoodsData.goodsStandard.moreStandard){
					this.addGoodsData.goodsStandard.standardViewVoList=[];
					this.addGoodsData.goodsStandard.allStandardViewVoList[0]=this.addGoodsData.goodsStandard.addStandard.one.standardVal;
					this.addGoodsData.goodsStandard.allStandardViewVoList[1]=this.addGoodsData.goodsStandard.addStandard.two.standardVal;
					this.addGoodsData.goodsStandard.allStandardViewVoList[2]=this.addGoodsData.goodsStandard.addStandard.three.standardVal;
					this.addGoodsData.goodsStandard.standardViewVoList=this.Public.arraysplitAll(this.addGoodsData.goodsStandard.allStandardViewVoList);
				}else{
					this.addGoodsData.goodsStandard.standardViewVoList=[];
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList = [{standardIsDel:true,standardIsDelText:"1",standardImg:"",standardValOne:"无",	standardValTwo:"",standardValThree:"",standardPic:"",standardBarCode:"",canUpload:true,uploading:false}]

				}
			},
			trHoverFnEnter(index){
				if(this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDel){
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDelText = "删除";
				}
			},
			trHoverFnLeave(index){
				if(this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDel){
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDelText = index+1;
				}
			},
			delStandardFn(index){
				/* 判断是否为最后一个删除 */
				let delLastRow = 0;
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList.forEach((item,index,arr)=>{
					if(item.standardIsDel){
						delLastRow++;
					}
				});
				/* 点击逻辑 */
				if(this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDel){
					if(1<delLastRow){
						this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDelText = "恢复";
						this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDel =　false;
						this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].canUpload =　false;
					}else{
						this.Public.openError(this,"请至少保留一种规格")
					}
				}else{
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDelText = "删除";
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].standardIsDel =　true;
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[index].canUpload =　true;
				}
			},
			tableImageuploaded(res){

			},
			tableImagechanged(res){
				this.addGoodsData.goodsStandard.uploadData.fileName = res.name;

			},
			tableImageuploading(res){
				this.addGoodsData.goodsStandard.uploadData.fileName = res.name;

			},
			tableErrorhandle(error){
				this.addGoodsData.goodsStandard.uploadData.fileName = res.name;

			},
			/* start 图片上传 */
			nowIndex(index){
				if(this.addGoodsData.goodsStandard.canUpload){
					this.addGoodsData.goodsStandard.uploadImgIndex = index;
				}else{
					this.Public.openError(this,"上一张图片上传中，请稍等...")
				}
			},
      handleAvatarChange(file, fileList){
//    	debugger;

      },
      beforeAvatarUpload(file) {
      	this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].uploading = true;
      	this.addGoodsData.goodsStandard.canUpload = false;
      	this.addGoodsData.goodsStandard.uploadData.fileName = file.name;
        const isJPG = file.type === 'image/jpeg';
        const isPNG = file.type === 'image/png';
        const isLt2M = file.size / 1024 / 1024 < 2;

        if (!isJPG&&!isPNG) {
        	this.Public.openError(this,"上传头像图片只能是 JPG和PNG 格式!")
					this.addGoodsData.goodsStandard.canUpload = true;
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].uploading = false;
        }

        if (!isLt2M) {
        	this.Public.openError(this,"上传头像图片大小不能超过 2MB!")
					this.addGoodsData.goodsStandard.canUpload = true;
					this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].uploading = false;
        }
        return (isPNG || isJPG) && isLt2M;
      },
      handleAvatarProgress(event, file, fileList){

      },
			handleAvatarSuccess(res, file,fileList) {
				this.addGoodsData.goodsStandard.canUpload = true;
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].uploading = false;
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].standardImg = res;
      },
      handleAvatarError(err,file,fileList){
				this.addGoodsData.goodsStandard.canUpload = true;
				this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList[this.addGoodsData.goodsStandard.uploadImgIndex].uploading = false;
      },
			/* end 图片上传 */
			/* end 商品规格 */
			/* start 商品图片 */
      picBeforeAvatarUpload(file) {
      	this.addGoodsData.goodsPic.uploadData.fileName = file.name;
        const isJPG = file.type === 'image/jpeg';
        const isPNG = file.type === 'image/png';
        const isLt2M = file.size / 1024 / 1024 < 2;

				if(this.addGoodsData.goodsPic.fileListLength>19){
					this.Public.openError(this,"最多只能上传20张");
				}
        if (!isJPG&&!isPNG) {
        	this.Public.openError(this,"上传头像图片只能是 JPG和PNG 格式!")
        }

        if (!isLt2M) {
        	this.Public.openError(this,"上传头像图片大小不能超过 2MB!")
        }
        return (isPNG || isJPG) && isLt2M && this.addGoodsData.goodsPic.fileListLength<=19;
      },
      picPreview(file) {
        this.addGoodsData.goodsPic.dialogImageUrl = file.url;
        this.addGoodsData.goodsPic.dialogVisible = true;
      },
      picRemove(file, fileList) {
  			this.addGoodsData.goodsPic.fileListLength = fileList.length;
      	if(fileList.length<20){
      		this.addGoodsData.goodsPic.canUpload = true;
      	}
      	//去除当前图片的服务器路径
      	var goodsPicUrlArr = this.addGoodsData.goodsPic.goodsPicUrls.split(file.response+",");
      	this.addGoodsData.goodsPic.goodsPicUrls = goodsPicUrlArr[0]+goodsPicUrlArr[1];
      },
      picChange(file,fileList){
  			this.addGoodsData.goodsPic.fileListLength = fileList.length;
      	if(fileList.length>=20){
      		this.addGoodsData.goodsPic.canUpload = false;
      	}
      },
      picSuccess(response, file, fileList){
      	//拼接图片服务器路径
      	this.addGoodsData.goodsPic.goodsPicUrls += response+",";
      },
			/* end 商品图片 */
			/* start goodsDes */

			/* end goodsDes */
			/* start save */
			saveFn(){
				let standardB = false;
				if(!this.addGoodsData.goodsStandard.moreStandard){
					standardB = true;
				}else{
					if(this.addGoodsData.goodsStandard.addStandard.one.isShow&&this.addGoodsData.goodsStandard.addStandard.two.isShow&&this.addGoodsData.goodsStandard.addStandard.three.isShow){
						if(""==this.addGoodsData.goodsStandard.addStandard.one.standardName){
							this.Public.openError(this,"请补充第1类规格名称")
						}else{
							if(!this.addGoodsData.goodsStandard.addStandard.one.standardVal.length){
								this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.one.standardName+"】")
							}else{
								if(""==this.addGoodsData.goodsStandard.addStandard.two.standardName){
									this.Public.openError(this,"请补充第2类规格名称")
								}else{
									if(!this.addGoodsData.goodsStandard.addStandard.two.standardVal.length){
										this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.two.standardName+"】")
									}else{
										if(""==this.addGoodsData.goodsStandard.addStandard.three.standardName){
											this.Public.openError(this,"请补充第3类规格名称")
										}else{
											if(!this.addGoodsData.goodsStandard.addStandard.three.standardVal.length){
												this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.three.standardName+"】")
											}else{
												standardB = true;
											}
										}
									}
								}
							}
						}
					}else if(this.addGoodsData.goodsStandard.addStandard.one.isShow&&this.addGoodsData.goodsStandard.addStandard.two.isShow){
						if(""==this.addGoodsData.goodsStandard.addStandard.one.standardName){
							this.Public.openError(this,"请补充第1类规格名称")
						}else{
							if(!this.addGoodsData.goodsStandard.addStandard.one.standardVal.length){
								this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.one.standardName+"】")
							}else{
								if(""==this.addGoodsData.goodsStandard.addStandard.two.standardName){
									this.Public.openError(this,"请补充第2类规格名称")
								}else{
									if(!this.addGoodsData.goodsStandard.addStandard.two.standardVal.length){
										this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.two.standardName+"】")
									}else{
										standardB = true;
									}
								}
							}
						}
					}else{
						if(""==this.addGoodsData.goodsStandard.addStandard.one.standardName){
							this.Public.openError(this,"请补充第1类规格名称")
						}else{
							if(!this.addGoodsData.goodsStandard.addStandard.one.standardVal.length){
								this.Public.openError(this,"请补全规格【"+this.addGoodsData.goodsStandard.addStandard.one.standardName+"】")
							}else{
								standardB = true;
							}
						}
					}
				}
				if(standardB){
					this.$refs.ruleForm.validate((valid)=>{
						if(valid){
							/* start 对排序值进行处理 */
							this.addGoodsData.basicInfo.orderBy = isNaN(this.addGoodsData.basicInfo.orderBy*1)?"0":this.addGoodsData.basicInfo.orderBy;
							/* end 对排序值进行处理 */
							/* start 对商品标签数据进行处理 */
							this.addGoodsData.basicInfo.goodsTags = "";
							this.addGoodsData.basicInfo.goodsTagsList.forEach((item,index,arr)=>{
								if(item.isCheckbox){
									this.addGoodsData.basicInfo.goodsTags += item.ddlistCode+",";
								}
							});
							this.addGoodsData.basicInfo.goodsTags = this.addGoodsData.basicInfo.goodsTags.substring(0,this.addGoodsData.basicInfo.goodsTags.length-1);
							/* end 对商品标签数据进行处理 */
							/* start 对商品规格进行处理 */
							let _index = 0;
							this.addGoodsData.goodsStandard.standardPicAjax = "";
							this.addGoodsData.goodsStandard.saleGoodsSkuViewVoList.forEach((item,index,arr)=>{
								item.standardPic = item.standardPic?item.standardPic:"0";  //价格如果没填，默认为0
								if(item.standardIsDel){
									this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index] = {};
									this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index].goodsBigPic = item.standardImg;
									if(this.addGoodsData.goodsStandard.addStandard.two.isShow&&this.addGoodsData.goodsStandard.addStandard.three.isShow){
										this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index].goodsSkuValue = this.addGoodsData.goodsStandard.addStandard.one.standardName+":\r"+item.standardValOne+","+this.addGoodsData.goodsStandard.addStandard.two.standardName+":\r"+item.standardValTwo+","+this.addGoodsData.goodsStandard.addStandard.three.standardName+":\r"+item.standardValThree;
									}else if(this.addGoodsData.goodsStandard.addStandard.two.isShow&&!this.addGoodsData.goodsStandard.addStandard.three.isShow){
										this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index].goodsSkuValue = this.addGoodsData.goodsStandard.addStandard.one.standardName+":\r"+item.standardValOne+","+this.addGoodsData.goodsStandard.addStandard.two.standardName+":\r"+item.standardValTwo;
									}else{
										this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index].goodsSkuValue = this.addGoodsData.goodsStandard.addStandard.one.standardName+":\r"+item.standardValOne;
									}
									this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax[_index].goodsBarCode = item.standardBarCode;
									this.addGoodsData.goodsStandard.standardPicAjax += item.standardPic+",";
									_index++;
								}
							});
							this.addGoodsData.goodsStandard.standardPicAjax = this.addGoodsData.goodsStandard.standardPicAjax.substring(0,this.addGoodsData.goodsStandard.standardPicAjax.length-1);
							/* end 对商品规格进行处理 */
							/* start 对 goodsDes数据进行处理*/
							/* end 对 goodsDes数据进行处理*/
							/* start 请求save接口 */
							this.clickBtn=!this.clickBtn;
							this.axios({
								method:"post",
								url:"/v3/sale/goodss",
								data:{
									"goodsName":this.addGoodsData.basicInfo.goodsName,
									"brandCode":this.addGoodsData.basicInfo.brandCode,
									"categoryCode":this.addGoodsData.basicInfo.categoryCode,
									"orderBy":this.addGoodsData.basicInfo.orderBy,
									"goodsNumUnit":this.addGoodsData.basicInfo.goodsNumUnitName,
									"goodsKeywords":this.addGoodsData.basicInfo.goodsKeywords,
									"goodsShowName":this.addGoodsData.basicInfo.goodsShowName,
									"goodsTags":this.addGoodsData.basicInfo.goodsTags,
									"goodsDesc":this.addGoodsData.goodsDes.goodsDesc,
									"goodsDesc1":this.addGoodsData.goodsDes.goodsDesc1,
									"goodsSalePrice":this.addGoodsData.goodsSalePrice,
									"goodsSalePrice1":this.addGoodsData.goodsSalePrice1,
									"saleGoodsSkuViewVoListStr":JSON.stringify(this.addGoodsData.goodsStandard.saleGoodsSkuViewVoListAjax),
									//"goodsSalePriceStr":this.addGoodsData.goodsStandard.standardPicAjax,
									"goodsGradePriceListStr":JSON.stringify(this.memberGradeData),
									"goodsPicUrls":this.addGoodsData.goodsPic.goodsPicUrls,
									"goodsSalePriceStr":this.addGoodsData.goodsStandard.standardPicAjax,
									"applyChoice":this.addGoodsData.basicInfo.isPutaway
								}
							}).then((res)=>{
									this.clickBtn=!this.clickBtn;
									this.$router.push({path:"/goods"});
									this.Public.openSuccess(this,"操作成功！");
							}).catch((err)=>{
									this.clickBtn=!this.clickBtn;
						      this.Public.openError(this,err.response.data)
					    });
							/* end 请求save接口 */
						}else{
							this.Public.openError(this,"按页面提示信息修改后才能提交")
							return false;
						}
					})
				}
			},
			/* end save */
			/* start cancel */
			cancel(){
				this.$router.go(-1)
			},
			/* end cancel */
      handleClick(tab,event){
      	if("1"==this.addGoodsData.goodsDes.title){
      	}else if("2"==this.addGoodsData.goodsDes.title){
      	}
      },
      

			// 查询所有运费模板集合
			trans_freight_queryAll(){
				this.axios({
					method: 'POST',
					url: "/v3/trans/freights/listAll",
					data:{

					},
					params:{
					}
				}).then((res) => {
					this.transFreightOption = res.data.list;
				}).catch((err)=>{
					this.Public.openError(this, err.response.data);
			  });
			 }, 
				//add more ajax methods
	},      

		created(){
			this.queryBrandList();  //请求商品品牌数据
			this.querycategoryList();  //请求商品分类数据
			this.queryUnit();  //请求计量单位
			this.queryBasicDdtype();  //请求商品标签
			this.queryListAll();
			this.trans_freight_queryAll();	// 查询所有运费模板列表
		},
		mounted(){

			let _this = this;
			this.addGoodsData.goodsDes.editor1 = UE.getEditor('addGoodsEditor1');
			this.addGoodsData.goodsDes.editor2 = UE.getEditor('addGoodsEditor2');
			this.addGoodsData.goodsDes.editor1.addListener("contentChange",function(){
				_this.addGoodsData.goodsDes.goodsDesc = this.getContent()
			});
			this.addGoodsData.goodsDes.editor2.addListener("contentChange",function(){
				_this.addGoodsData.goodsDes.goodsDesc1 = this.getContent()
			})
			document.querySelector(".addGoodsWrap form").style.height = (document.documentElement.clientHeight - 180) + 'px';
			document.querySelector("body").onclick = ()=>{
				this.addGoodsData.basicInfo.treeShow = false;
			}
				//帮助功能
			this.systemTemplateAjax();
		},
	  destroyed() {
	    this.addGoodsData.goodsDes.editor1.destroy();
	    this.addGoodsData.goodsDes.editor2.destroy();
	  }

	}
</script>

<style scoped>

	*{
		box-sizing: border-box;
		transition: .2s;
	}
  section {
    display: flex;
    flex-direction: column;
    flex: 1;
  }

  div.location {
    flex: 0 0 10px;
    padding: 3px 0 15px 0;
  }

	div.wrap {
		position: relative;
		flex: 1;
		width: 100%;
		padding: 15px 20px 0 20px;
		box-sizing: border-box;
		background: #fff;
	}
	div.wrap>form {
		overflow-y: auto;
	}
	.scroll {
		overflow-y: auto;
		overflow-x:hidden;
		padding-right: 20px;
	}
	.title {
		height: 50px;
		color: #03B8CC;
		font-size: 16px;
	}
	.selectWidth {
		width: 100%;
	}
	/* start 基础信息 */
 /* start 商品分类下拉的样式 */
.departmentSelectDiv {
	position: relative;
	width: 100%;
	height: 36px;
	line-height: 36px;
}
.departmentSelectDiv>span{
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 36px;
	border:1px solid rgb(191, 212, 217);
	border-radius: 4px;
	font-size: 12px;
	padding-left: 10px;
	cursor: pointer;
}
.departmentSelectDiv>span:hover{
	border-color: rgb(131, 156, 165);
}
.departmentSelectDiv>span:active{
	border-color: #03b8cc;
}
.departmentSelectDiv>span:visited{
	border-color: #03b8cc;
}
.departmentSelectDiv>span:focus{
	border-color: #03b8cc;
}
.departmentSelectDiv>i{
	position: absolute;
	top: 0;
	right: 0;
	width: 35px;
	height: 36px;
	line-height: 38px;
	text-align: center;
	color: rgb(191, 212, 217);
	transition: .3s;
	font-size: 12px;
}
.departmentSelectDiv>i.up{
	transform: rotate(180deg);
}
.goodsCate{
	position: absolute;
	width: 100%;
	height: 236px;
	top: 42px;
	left: 0;
	border-radius: 2px;
	box-shadow:0 2px 4px rgba(0,0,0,.12), 0 0 6px rgba(0,0,0,.04);
	border: 1px solid rgb(209, 225, 229);
	z-index: 2;
	font-size: 12px;
	background:#fff;
}
.goodsCateBtn{
	cursor:pointer;
	padding-left:12px;
	line-height:32px;
	border-top:1px solid #e9e9e9;
}
.goodsCateBtn>span{
	font-size:12px;
}
.departmentTree {
	width: 100%;
	z-index: 2;
	font-size: 12px;
	overflow-y: auto;
	height: 200px;
	border:0;
}
.selectSlide-enter-active, .selectSlide-leave-active {
    transition: .4s;
  }

  .selectSlide-enter, .selectSlide-leave-active {
    height: 0;
    opacity: 0;
  }
  .redBorder {
  	border-color: #ff4949 !important;
  }
 /* end 商品分类下拉的样式 */
/* start 商品分类的下拉新增 */
	.goodsCateAdd {
		position: absolute;
		width: 100%;
		top: 42px;
		left: 0;
		border-radius: 2px;
		box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
		border: 1px solid rgb(209, 225, 229);
		z-index: 2;
		font-size: 12px;
		background: #fff;
	}

	.departmentTreeAdd {
		width: 100%;
		z-index: 2;
		font-size: 12px;
		overflow-y: auto;
		height: 200px;
		border: 0;
	}
	/* end 商品分类的下拉新增 */
/* start 排序 */
.orderByDiv .btnSpan {
	display: block;
	position: absolute;
	height: 18px;
	width: 18px;
	line-height: 18px;
	text-align: center;
	margin: 0;
	padding: 0;
	right: 0;
	cursor: pointer;
	z-index: 1800;
	border:1px solid rgb(191, 212, 217);
	border-right: 0;
	-moz-user-select: none; /* 禁止文本被选中 */
}
.orderByDiv .btnSpan:hover {
	color: #13C19F;
}
.orderByDiv .btnSpan.orderByBtnAdd {
	top: 0;
	border-top: 0;
}
.orderByDiv .btnSpan.orderByBtnSub {
	top: 18px;
	border-bottom: 0;
}
/* start 排序 */
	/* end 基础信息 */
	/* start 商品规格 */
	.tableWrap {
	}
	.tableHeader{
		background-color: #eff1f8;
    padding: 0 10px;
    line-height: 50px;
	}
	.setStandardTable{
		width: 100%;
		background: #fff;
		border:1px solid #e7e9f1;
		margin-bottom: 20px;
	}
	.setStandardTable tr:nth-of-type(1) th{
		padding: 20px 0 5px 5px;
		text-align: left;
		font-weight: 400;
	}
	.setStandardTable tr+tr:hover{
		background-color:#F8F9FD;
	}
	.setStandardTable tr td {
		padding: 5px;
		font-weight: 400;
		height: 50px;
		line-height: 50px;
	}
	.addBtnI:before {
		margin-right: 10px;
	}
	.batchOper {
		margin: 5px 0;
	}
	.batchOper span{
		display: inline-block;
	}
	.showStandardTable {
		width: 100%;
		background: #fff;
		border: 1px solid #e7e9f1;
		margin-bottom: 22px;
	}
	.showStandardTable tr:nth-of-type(1) th{
		height: 50px;
		line-height: 50px;
		text-align: center;
		font-weight: 400;
		background: #eff1f8;
	}
	.showStandardTable tr+tr:hover{
		background-color:#F8F9FD;
	}
	.showStandardTable tr td {
		padding: 5px;
		font-weight: 400;
		text-align: center;
		height: 50px;
		line-height: 50px;
	}
	.addPicTd {
		position: relative;
	}
	.cursorPo {
		cursor: pointer;
	}
	.textAlignC {
		text-align: center;
	}
	.borderL {
		border-left:1px solid #e7e9f1 ;
	}
	.borderR {
		border-right:1px solid #e7e9f1 ;
	}
	.borderT {
		border-top:1px solid #e7e9f1 ;
	}
	.borderB {
		border-bottom:1px solid #e7e9f1 ;
	}
	/* end 商品规格 */
	.btnBox {
		position: absolute;
		bottom: 10px;
		left:180px;
		height: 50px;
		background: #fff;
		z-index: 100;
	}
	.btnBox1 {
		left:98px;
	}
	/* start 商品标签 */
	.goodsLabel {
		display: inline-block;
		position: relative;
    min-width: 80px;
    line-height: 32px;
    padding: 0 20px;
    margin: 0 10px 10px 0;
    text-align: center;
    cursor: pointer;
	}
	.checkboxSpan {
		position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 1px solid #cdd9e6;
	}
	.checkboxSpan.active {
		background: url('../../../assets/img/goodsLabelCheckbox.png') 100% 100% no-repeat;
		border-color: #00c29f;
	}
	.checkboxInput {
		display: none;
	}
	.checkboxText {
		font-size: 12px;
	}
	/* end 商品标签 */
	/* start 富文本编辑器 */
	.quillEditor {
		width: 90%;
		height: 400px;
		margin-bottom: 30px;
	}
	.ueditor {
		width:500px;
		height: 400px;
		margin-bottom: 30px;
	}
	/* end 富文本编辑器 */
	/* start upload */
	.avatar-uploader {
		display: inline-block;
	}
	.avatar-uploader .el-upload {
		vertical-align: middle;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    line-height: 40px !important;
    overflow: initial !important;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #20a0ff;
  }
  .avatar-uploader-icon {
    font-size: 12px;
    color: #8c939d;
    width: 40px;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
  .avatar {
    width: 40px;
    height: 40px;
    display: block;
  }
  .addgoodTab{
  	border-left: 1px solid rgb(223, 234, 236) ;
  	border-top: 1px solid rgb(223, 234, 236) ;
  	clear: both;
  	margin-top: 15px;
  }
  .Tbuttom{
  	margin-top: 25px;
  }
  .shichangjia{
  	width: 800px;
  	overflow: hidden;
  }
  .shichangjia span{
  	float: left;
  	line-height: 32px;
  	margin-right: 10px;
  }
  .shichangjia input{
  	width: 300px;
  	float: left;

  }
  /* start 下拉的按钮样式 */
 .kael{
 	position:absolute;
 	width:100%;
 	bottom:0;
 	left:0;
 	border-top:1px solid #e9e9e9;
 	background:#fff;
 	padding:6px 10px;
 }
 .kael>span{
 	color:#48626a;
 }
  /* end 下拉的按钮样式 */
	/*.avatar-uploader{
		cursor: pointer !important;
	}
	.avatar-uploader:hover .avatar-uploader-icon {
		border-color: #03B8CC;
	}
	.avatar-uploader-icon {
    border-radius: 6px;
		font-size: 12px;
		padding: 15px;
		border: 1px dashed #d9d9d9;
	}
	.crop-box .g-resize {
		background-color: red !important;
	}*/
	/* end upload */
</style>
